package main

import (
	"fmt"
	"time"
)

func hello()  {
	for i:=0;i<5;i++ {
		fmt.Println("hello()...")
		time.Sleep(time.Second)
	}
}

func test()  {

	//使用defer+recover捕获异常
	defer func ()  {
		if err:=recover();err!=nil {
			fmt.Println("-----------------test()...")
		}
	}()

	/*
		map没有make就是用报panic错误
	*/
	var myMap map[int]string
	myMap[0] = "1"
}

func main()  {
	go hello()
	go test()

	for i:=0;i<10;i++ {
		time.Sleep(time.Second)
		fmt.Println("main()...")
	}
}
